<?php

namespace App\Models\User;

use App\Models\BaseModel;
//use App\Models\User\UserClient;

/**
 * 用户模型层
 *
 * Class Role
 * @package App\Models\User
 */
class UsersInfo extends BaseModel
{
    protected $table = 'users_info';

    public $timestamps        = false;
    public $operate           = [0=> '未选择', 1=>'艺人',2=>'乐队'];
    public $request           = [0=> '推广', 1=>'赚钱'];
    public $major             = [0=> '未选择', 1=>'原唱歌手',2=>'歌手',3=>'乐手',4=>'词作者',5=>'曲作者'];
    public $phone_major       = [0=> '未选择', 1=>'主唱',2=>'歌手',3=>'乐手',4=>'词作者',5=>'曲作者'];
    public $type              = [0=> '未选择', 1=>'音乐人',2=>'音乐团体',3=>'经纪人',4=>'厂牌'];
    public $copyright_number  = [0=> '未选择', 1=>'100首以内', 2=>'101-500首', 3=>'501-3000首', 4=>'3001首以上'];
    public $language          = [0=> '未选择', 1=>'中文-简体', 2=>'中文-繁体', 3=>'中文繁体-English', 4=>'English'];
    public $company_business  = [0=> '未选择', 1=>'音乐生产', 2=>'艺人管理/经营', 3=>'版权管理/代理'];
    public $status            = [0=> '未审核', 1=>'审核中',2=>'已审核',3=>'暂时停用',4=>'打回',5=>'注销'];
    public $phone_time        = [0=> '未选择', 1=>'10：00-12：00',2=>'13：00-17：00',3=>'18：00-23：00',4=>'不限时间'];
    public $phone_quality     = [0=> '未选择', 1=>'非常好',2=>'比较好',3=>'一般',4=>'比较一般',5=>'差'];
    public $computer_capacity = [0=> '未选择', 1=>'PC高手',2=>'Mac高手',3=>'PC一般',4=>'Mac一般',5=>'PC初级',5=>'Mac初级',7=>'不会用'];
    protected $guarded = [];

    public $appends = ['phone_time_text', 'major_text', 'type_text', 'operate_text'];

    public function users(){
       return $this->belongsTo('App\Models\User\Users','user_id', 'id');
    }

    public function deal(){
        return $this->hasMany('App\Models\Deal\Deal','user_id','id');
    }

    public function callRecord()
    {
        return $this->hasMany('App\Models\CallRecord\CallRecord', 'calledid','phone');
    }

    public function incomeExcel()
    {
        return $this->hasMany('App\Models\Finance\IncomeExcel', 'user_id', 'id');
    }

    public static function setPhoneStatus($value)
    {
        if($value=='电话接通'){
            $phone_status = 0;
        }elseif ($value=='无人接听'){
            $phone_status = 1;
        }
        return $phone_status;
    }

    public function music(){
        return $this->hasMany('App\Models\Music\Music','user_id','id');
    }

    public function agent(){
        return $this->haoOne('App\Models\Agent\Agent','software_id','software_id');
    }

    public function getMajorTextAttribute(){
        return $this->major[$this['major']??0];
    }

    public function getExpiredTimeAttribute($value){
        return date('Y-m-d H:i:s',$value);
    }

    public function getTypeTextAttribute(){
        return $this->type[$this['type']??0];
    }

    public function getOperateTextAttribute(){
        return $this->operate[$this['operate']??0];
    }

    public function getStatusAttribute($value){
        return $this->status[$value];
    }

    public function getPhoneTimeTextAttribute()
    {
        return $this->phone_time[$this['phone_time']??0];
    }

    public function getPhoneQualityAttribute($value)
    {
        return $this->phone_quality[$value];
    }

    public function getComputerCapacityAttribute($value)
    {
        return $this->phone_quality[$value];
    }

}
